#include "mat_sounds.h"

const std::string MATSounds::MUSIC_MENU = "sounds/mat_music_menu.ogg";
const std::string MATSounds::MUSIC_INGAME = "sounds/mat_music_ingame.ogg";	

MATSounds::MATSounds()					
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		m_PlayCounters[i] = 0;
	}
}

MATSounds&	MATSounds::Instance()
{
	static MATSounds	Inst;
	return Inst;
}

void		MATSounds::PlayMusic(const std::string& Name)
{
	AUDIO().PlayMusic(Name);

}

void		MATSounds::PlaySoundSFX(SOUND_NAMES SFXEnum)
{
	m_PlayCounters[(int)SFXEnum] = 0.001f;
	
}

void		MATSounds::Tick(float dt)
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		if( m_PlayCounters[i] > 0)
		{
			m_PlayCounters[i] -= dt;
			if(m_PlayCounters[i] <= 0)
			{
				InternalPlay((MATSounds::SOUND_NAMES)i);
			}
		}
	}	
}


void		MATSounds::InternalPlay(SOUND_NAMES SFXEnum)
{
	switch(SFXEnum)
	{
		case SFX_NONE:
		break;

		case SFX_MATCH:
			AUDIO().PlayEvent("match");
			break;

		case SFX_GEM_MOVING:
			AUDIO().PlayEvent("fig_explosion_verybig");			
		break;

		case SFX_GEM_SELECTED:
			AUDIO().PlayEvent("gem_select");			
		break;

		case SFX_GEM_MOVE_START:
			AUDIO().PlayEvent("gem_move_start");			
		break;

		case SFX_GEM_COLEECTED:
			AUDIO().PlayEvent("gem_collected");				
		break;

		case UI_CLICK:
			break;

		case UI_POPUP:
			AUDIO().PlayEvent("popup_open");
			break;

		case UI_SCORE_TICK:
			AUDIO().PlayEvent("ui_score_tick");		
			break;

		case SFX_BONUS_TIME:
			AUDIO().PlayEvent("bonus_time");		
			break;

		case SFX_NOTVALIDMOVE:
			AUDIO().PlayEvent("not_valid_move");		
			break;

		case SFX_RATINGSTAR_APPEAR:
			AUDIO().PlayEvent("rating_star_appear");		
			break;

		case SFX_LEVEL_FULLSTAR:
			AUDIO().PlayEvent("level_fullstar");				
			break;

		case SFX_LEVEL_SUCCESS:
			AUDIO().PlayEvent("level_success");	
			break;

		case SFX_LEVEL_FAIL:
			AUDIO().PlayEvent("level_fail");	
			break;

		case SFX_LEVEL_CLICKED:
			AUDIO().PlayEvent("level_clicked");			
			break;

		case SFX_EXPLODE_BOMB:
			AUDIO().PlayEvent("bomb_explode");			
			break;

		case SFX_EXPLODE_TRAP:
			AUDIO().PlayEvent("trap_explode");			
			break;

		case SFX_EXPLODE_TILE:
			AUDIO().PlayEvent("tile_explode");			
			break;
			
		case SOUND_NAMES_C:
			break;		

		default:
			break;

	}
}

